package com.dy.design_pattern_study.singleton_pattern.dome1;

import com.dy.design_pattern_study.utils.Utils;

/**
 * @CreateBy zhangdingyi
 * @Date 2023-04-17
 * @Content
 */
public class client {
    public static void main(String[] args) {
        //直接调用会报错
        //Singleton instance1 = new Singleton();
        //因此这里仅可以调用方法进行创建
        Singleton instance1 = Singleton.getSingleton();
        Singleton instance2 = Singleton.getSingleton();


        if (instance1 == instance2){
            System.out.println("两个对象一致，因为地址一致");
            String address1 = Utils.getAddress(instance1);
            System.out.println("address1 = " + address1);
            String address2 = Utils.getAddress(instance2);
            System.out.println("address2 = " + address2);
        }
    }
}
